﻿namespace IdentityService.Domain.Entities;

public class User : IdentityUser<Guid>, IHasCreatedTime, IHasDeletedTime, ISoftDelete
{
    public DateTimeOffset CreatedTime { get; init; }
    public DateTimeOffset DeletedTime { get; private set; }

    public bool IsDeleted { get; private set; }
    
    public string Name { get; private set; }
    
    public string Avatar { get; private set; }

    public User(string userName, string name, string avatar) : base(userName)
    {
        Name = name;
        Avatar = avatar;
        Id = Guid.NewGuid();
        CreatedTime = DateTimeOffset.UtcNow;
    }

    public void ChangeName(string name)
    {
        Name = name;
    }

    public void ChangeAvatar(string avatar)
    {
        Avatar = avatar;
    }

    public void SoftDelete()
    {
        this.IsDeleted = true;
        this.DeletedTime = DateTimeOffset.UtcNow;
    }
}